package com.feeyo.groundservice.checkin.model

import com.feeyo.groundservice.base_util.upToInt
import com.feeyo.groundservice.checkin.constant.NodeType

/**
 *作者：70893 on 2025-10-29
 *描述：
 */


internal data class CheckInTaskBO(
    val task_list: List<CheckInTaskItemBO>,
    val user: CheckInUserBO,//是谁的任务
    val checked_time: Long,//已完成的值机任务的时长
    val checked_count: Int,//已完成的值机任务次数
) {
    val totalTime: String
        get() = "${(checked_time / 60f).upToInt()}分钟"
}

internal data class CheckInTaskItemBO(
    val task: TaskBO,
    val focus_data: FocusDataBO,
    val node: List<NodeBO> = emptyList(),//节点
) {
    val startNode: NodeBO?
        get() = node.firstOrNull { it.nmode == NodeType.START.type }
    val endNode: NodeBO?
        get() = node.firstOrNull { it.nmode == NodeType.END.type }
}

internal data class TaskBO(
    val id: String,
    private val ps: Long,//计划开始时间
    private val pe: Long,//计划结束时间
    private val rs: Long,//实际开始时间
    private val re: Long,//实际结束时间
    val truename: String,//调度员
) {
    val startTime: Long
        get() = if (rs == 0L) ps else rs

    val endTime: Long
        get() = if (re == 0L) pe else re

    val isStart: Boolean
        get() = rs > 0L

    val isEnd: Boolean
        get() = re > 0L
}

internal data class FocusDataBO(
    val focus_info: String,//柜台
)